package com.miya.controller;

import java.util.Arrays;
import java.util.Map;

import com.miya.entity.TSalaryEntity;
import com.miya.common.utils.PageUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.miya.service.TSalaryService;
import com.miya.common.utils.R;



/**
 * 个人薪资记录表
 *
 * @author caixiaowei
 * @email 540110865@qq.com
 * @date 2018-11-08 19:20:17
 */
@RestController
@RequestMapping("admin/tsalary")
@Api(tags = "个人资产")
@Slf4j
public class TSalaryController {
    @Autowired
    private TSalaryService tSalaryService;

    /**
     * 列表
     */
    @PostMapping("/list")
    @ApiOperation(value="列表")
//    @RequiresPermissions("admin:tsalary:list")
    public R list(@RequestBody Map<String, Object> params){
        PageUtils page = tSalaryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @RequiresPermissions("admin:tsalary:info")
    public R info(@PathVariable("id") Integer id){
			TSalaryEntity tSalary = tSalaryService.selectById(id);

        return R.ok().put("tSalary", tSalary);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @RequiresPermissions("admin:tsalary:save")
    public R save(@RequestBody TSalaryEntity tSalary){
			tSalaryService.insert(tSalary);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @RequiresPermissions("admin:tsalary:update")
    public R update(@RequestBody TSalaryEntity tSalary){
			tSalaryService.updateById(tSalary);

        return R.ok();
    }

    /**
     * 删除
     */
    @GetMapping("/delete")
    @RequiresPermissions("admin:tsalary:delete")
    public R delete(@RequestBody Integer[] ids){
			tSalaryService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
